﻿using cn.jpush.api.util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace MyPush
{
    public class JsonToolExt
    {
        public static string DictionaryToJson(Dictionary<string, HashSet<string>> dict)
        {
            if (dict == null)
                return null;
            List<string> jsons = new List<string>();
            foreach (KeyValuePair<string, HashSet<string>> hash in dict)
            {
                string arrJson = "[]";
                if (hash.Value != null)
                    arrJson = JsonTool.ObjectToJson(hash.Value);// "\"" + string.Join("\",\"", hash.Value) + "\"";
                string str = string.Format("\"{0}\":{1}", hash.Key, arrJson);
                jsons.Add(str);
            }
            return string.Join(",", jsons);
        }
    }
}
